GOFLAGS=-ldflags "-X \"main.version=`git rev-list HEAD | wc -l`\" -X \"main.commitID=`git rev-list HEAD | head -1`\""

BSEDIR = $(shell pwd)
BLDDIR = build

APPName = etcdkeeper
ifeq ($(OS),Windows_NT)
	APPS = ${APPName}.exe
else
	APPS = ${APPName}
endif

############################################################################################
.PHONY: all buildexe builddir clean docker

all: builddir buildexe

buildexe:
	@go mod tidy
	@go build ${GOFLAGS} -o ${BSEDIR}/${BLDDIR}/bin/${APPS} main.go
	@cp -fr assets ${BSEDIR}/${BLDDIR}
	
builddir:
	mkdir -p ${BSEDIR}/${BLDDIR}
	
clean:
	rm -fr $(BLDDIR)

docker:
	@docker-compose build